/**
 * Copyright &copy; 2015-2020 <a href="http://www.easyhis.com/">easyhis</a> All rights reserved.
 */
package com.easy.modules.iim.entity;

import com.easy.common.utils.IdGen;
import com.easy.core.persistence.BaseEntity;
import com.easy.modules.sys.utils.UserUtils;
import org.hibernate.validator.constraints.Length;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.easy.core.persistence.DataEntity;
import com.easy.modules.sys.entity.User;


/**
 * 发件箱Entity
 * @author easy
 * @version 2015-11-15
 */
public class MailBox extends BaseEntity<MailBox> {
	
	private static final long serialVersionUID = 1L;
	private String id;
	private Integer boxId;
	private Integer mailId;
	private String readStatus;		// 状态 0 未读 1 已读
	private User sender;		// 发件人
	private User receiver;		// 收件人
	private Date sendTime;		// 发送时间
	private Mail mail;		// 邮件外键 父类
	private String remarks;	// 备注
	private User createBy;	// 创建者
	private Date createTime;	// 创建日期
	private User updateBy;	// 更新者
	private Date updateTime;	// 更新日期
	private Integer sortNo;		// 排序
	private Integer delFlag; 	// 删除标记（0：正常；1：删除；2：审核）

	
	public MailBox() {
		super();
	}

	public MailBox(String id){
		this.id = id;
	}

	public MailBox(Mail mail){
		this.mail = mail;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Integer getBoxId() {
		return boxId;
	}

	public void setBoxId(Integer boxId) {
		this.boxId = boxId;
	}

	public Integer getMailId() {
		return mailId;
	}

	public void setMailId(Integer mailId) {
		this.mailId = mailId;
	}

	@Length(min=0, max=45, message="状态 0 未读 1 已读长度必须介于 0 和 45 之间")
	public String getReadStatus() {
		return readStatus;
	}

	public void setReadStatus(String readstatus) {
		this.readStatus = readStatus;
	}
	
	public User getSender() {
		return sender;
	}

	public void setSender(User sender) {
		this.sender = sender;
	}
	
	public User getReceiver() {
		return receiver;
	}

	public void setReceiver(User receiver) {
		this.receiver = receiver;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getSendTime() {
		return sendTime;
	}

	public void setSendTime(Date sendTime) {
		this.sendTime = sendTime;
	}
	
	@Length(min=0, max=64, message="邮件外键长度必须介于 0 和 64 之间")
	public Mail getMail() {
		return mail;
	}

	public void setMail(Mail mail) {
		this.mail = mail;
	}

	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	public User getCreateBy() {
		return createBy;
	}

	public void setCreateBy(User createBy) {
		this.createBy = createBy;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public User getUpdateBy() {
		return updateBy;
	}

	public void setUpdateBy(User updateBy) {
		this.updateBy = updateBy;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public Integer getSortNo() {
		return sortNo;
	}

	public void setSortNo(Integer sortNo) {
		this.sortNo = sortNo;
	}

	public Integer getDelFlag() {
		return delFlag;
	}

	public void setDelFlag(Integer delFlag) {
		this.delFlag = delFlag;
	}

	/**
	 * 插入之前执行方法，需要手动调用
	 */
	public void preInsert(){
		User user = UserUtils.getUser();
		if (user.getUserId()<1){
			this.updateBy = user;
			this.createBy = user;
		}
		this.updateTime = new Date();
		this.createTime = this.updateTime;
	}

	/**
	 * 更新之前执行方法，需要手动调用
	 */
	public void preUpdate(){
		User user = UserUtils.getUser();
		if (user.getUserId()<1){
			this.updateBy = user;
		}
		this.updateTime = new Date();
	}
}